package com.pls.handlers;

import java.util.ArrayList;

import com.pls.helpers.ExportToFile;
import com.plsContracts.dataContracts.SearchEmployeeRequest;
import com.plsContracts.dataContracts.SearchEmployeeResponse;
import com.plsDTO.dataObjects.Employee;
import com.plsDTO.validation.ValidationError;
import com.plsData.data.EmployeeData;

public class SearchEmployeeHandler extends
		RequestHandler<SearchEmployeeResponse, SearchEmployeeRequest> {

	public SearchEmployeeHandler(Class<SearchEmployeeResponse> tResponse) {
		super(tResponse);
		// TODO Auto-generated constructor stub
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.pls.handlers.RequestHandler#process(com.plsContracts.data.Request)
	 */
	protected ArrayList<ValidationError> validate(SearchEmployeeRequest request) {
		ArrayList<ValidationError> errors = new ArrayList<ValidationError>();
		ValidationError valError;
		if (request == null) {
			valError = new ValidationError();
			valError.setMessage("Request is null.");
			valError.setName("NullRequest");
			errors.add(valError);
			return errors;
		}
		if (request.getEmployeeId() == 0) {
			valError = new ValidationError();
			valError.setMessage("Employee Id cannot be null.");
			valError.setName("InvalidInput");
			errors.add(valError);
		}

		return errors;
	}

	protected SearchEmployeeResponse process(SearchEmployeeRequest request) {
		SearchEmployeeResponse response = new SearchEmployeeResponse();
		
		EmployeeData empData = new EmployeeData();
		response.setEmployeeWorkstation(empData.searchEmployeeById(request.getEmployeeId()));
		
		return response;

	}

}
